import service from '@/service';

export default {
	state: {
		token: null,
		userInfo: {},
	},
	mutations: {
		setToken(state, value) {
			state.token = value;
		},
		setUserInfo(state, value) {
			state.userInfo = value;
		}
	},
	actions: {
		// 设置token
		async token({ commit }, obj) {
			console.log(obj)
			uni.setStorageSync('token', obj.token);
			commit('setToken', obj.token);
		},
		// 获取用户信息
		async getUserInfo({ commit }) {
			const userInfo = await service.common.user.userInfo();
			commit('setUserInfo', userInfo);
		}
	}
};
